<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var s1=Symbol.for("name");  //定义一个symbol标签，key为name,如果存在则获取，不存在则创建
        var user={
            [s1]:"tom",
            [Symbol.for("age")]:29
        };

        var s2=Symbol.for("name");
        console.log(user[s2]);  //tom
        console.log(s2===s1);  //true
        console.log(user[Symbol.for("age")]);

        //获取symbol的key
        console.log(Symbol.keyFor(s2));
    </script>
</body>
</html>